﻿var vUserName = null;
var vData = null;
var objOpinion = null;
var staffID = "";
$(document).ready(function () {
    staffID = $.query.get("Staff_ID");
    vUserName = $.query.get("Staff_Name");
    //初始化对象
    var m_cksqdj = new SmObjectData("CKQDJK", "采矿申请登记");
    //获取流程号PROJECT_ID	
    var m_project_id = $.query.get("Project_ID");
    var m_splx = $.query.get("SPLX");
    //获取一条记录
    m_cksqdj.GetFirstSmObject("PROJECT_ID=\\\'" + m_project_id + "\\\'");
    //给申请页面赋值，并以颜色区分可不可编辑，分审批类型
    $(":text").each(function () {
        if ($(this).attr("id").indexOf("_") > 0) {
            $(this).css("display", "none");
            return;
        }
        $(this).css("background-color", "#E4E4E4");
        var ff = $(this).attr("name");
        $(this).val(m_cksqdj.GetValue(ff));
    });
    $("textarea").each(function () {
        $(this).css("background-color", "#E4E4E4");
        var dd = $(this).attr("name");
        $(this).val(m_cksqdj.GetValue(dd));
    });
    $(":button").each(function () {
        if ($(this).attr("id").indexOf("_") > 0) {
            $(this).css("display", "none");
        }
    });
    $("select").each(function () {
        if ($(this).attr("id").indexOf("_") > 0) {
            $(this).css("display", "none");
        }
    });
    $("table").css("display", "none");
    $("#MainTable3").css("display", "inline");
    $("span").css("display", "none");
    var objSel = null;
    var objSave = null;
    var objDel = null;


    //会审
    var hss = new SmDataTable("CKQDJK");
    hss.Init("select * from CKS_KQFWHSYJ where PROJECT_ID=\\\'" + m_project_id + "\\\'");
    if (hss != null && hss.Data.Rows.length > 0) {
        for (var i = 0; i < hss.Data.Rows.length; i++) {
            var mc = hss.Data.Rows[i][3];
            var yj = hss.Data.Rows[i][4];
            var strhtml = '<tr><td>' + mc + '会审意见：<br/></td>\
                        <td colspan="3"><textarea  name="HSYJ" tag="' + mc + '" class="m_textarea txtinput disabled"  disabled="disabled">' + yj + '</textarea></td>\
                    </tr>\
                    <tr>\
                        <td class="tdleft">会 审 人：</td>\
                        <td class="tdright"><input name="HSR" value="' + hss.Data.Rows[i][5] + '" type="text" tag="' + mc + '"  class="m_input txtinput disabled" disabled="disabled"/></td>\
                        <td class="tdleft">会审日期：</td>\
                        <td class="tdright"><input name="HSSJ" value="' + hss.Data.Rows[i][6] + '" type="text" tag="' + mc + '"  class="datetime m_input txtinput disabled" disabled="disabled"/></td>\
                    </tr>';
            $("#tblSCYJ").append(strhtml);
        }
    }
    /* for(i=0;i<kssm;i++)
    {
    var j=i+1;
    kss[i]=$.query.get("KSMC"+j);//记录该流程需要参加会审的科室
    objects[kss[i]]=new SmObjectData("CKQDJK","CKS_KQFWHSYJ");//new多个SmObjectData对象
    getObject(kss[i]).GetFirstSmObject("PROJECT_ID=\\\'"+m_project_id+"\\\' and HSLX=\\\'"+kss[i]+"\\\'");
    }
    InitPage();
    if(ksmc!=null && ksmc!="")
    {
    $(".datetime[tag='"+ksmc+"']").click(function(){WdatePicker({dateFmt:'yyyy-M-d'});});
    $("[tag='"+ksmc+"']").removeAttr("disabled");
    $("[tag='"+ksmc+"']").removeClass("disabled");
    }
    */

    //根据审批类型不同，控制其他审批内容不可用
    switch (m_splx) {
        case 11:
            //$("#tblKGC").css("display", "block");
            //            $("#tblDHC").css("display", "none");
            //$("#tblZSB").css("display", "block");
            //$("#tblGHC").css("display", "block");
            //   $("#tblDJC").css("display", "block");
        case 1:
            $("#tblSCYJ").css("display", "block");
            $("#txt审查人意见").removeAttr("disabled");
            $("#txt审查人").removeAttr("disabled");
            $("#txtSCRQ").removeAttr("disabled");
            $("#txt审查人意见").css("background-color", "white");
            $("#txt审查人").css("background-color", "white");
            $("#txtSCRQ").css("background-color", "white");
            $('span[name="审查人意见"]').css("display", "inline");
            GetNowDate($("#txtSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txt审查人"));
            objSel = $("#selOpinionModel_审查人意见");
            objSave = $("#btnOpenOpinionModel_审查人意见");
            objDel = $("#btnDelOpinionModel_审查人意见");
            objOpinion = $("#txt审查人意见");
            $("#selOpinionModel_审查人意见").css("display", "inline");
            $("#btnOpenOpinionModel_审查人意见").css("display", "inline");
            $("#btnDelOpinionModel_审查人意见").css("display", "inline");

            vUserName = $("#txt审查人");
            vData = $("#txtSCRQ");
            break;
        case 2:
            $("#tblSCYJ").css("display", "block");
            //$("#tblKGC").css("display", "block");
            $("#txtKGCYJ").removeAttr("disabled");
            $("#txtKGCSCR").removeAttr("disabled");
            $("#txtKGCSCRQ").removeAttr("disabled");
            $("#txtKGCYJ").css("background-color", "white");
            $("#txtKGCSCR").css("background-color", "white");
            $("#txtKGCSCRQ").css("background-color", "white");
            $('span[name="KGCYJ"]').css("display", "inline");
            GetNowDate($("#txtKGCSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtKGCSCR"));
            objSel = $("#selOpinionModel_KGCYJ");
            objSave = $("#btnOpenOpinionModel_KGCYJ");
            objDel = $("#btnDelOpinionModel_KGCYJ");
            objOpinion = $("#txtKGCYJ");
            $("#selOpinionModel_KGCYJ").css("display", "inline");
            $("#btnOpenOpinionModel_KGCYJ").css("display", "inline");
            $("#btnDelOpinionModel_KGCYJ").css("display", "inline");

            vUserName = $("#txtKGCSCR");
            vData = $("#txtKGCSCRQ");
            break;
        case 3:
            $("#tblSCYJ").css("display", "block");
            // $("#tblDHC").css("display", "block");
            $("#txtDHCSCYJ").removeAttr("disabled");
            $("#txtDHCSCR").removeAttr("disabled");
            $("#txtDHCSCRQ").removeAttr("disabled");
            $("#txtDHCSCYJ").css("background-color", "white");
            $("#txtDHCSCR").css("background-color", "white");
            $("#txtDHCSCRQ").css("background-color", "white");
            $('span[name="DHCSCYJ"]').css("display", "inline");
            GetNowDate($("#txtDHCSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtDHCSCR"));
            objSel = $("#selOpinionModel_DHCSCYJ");
            objSave = $("#btnOpenOpinionModel_DHCSCYJ");
            objDel = $("#btnDelOpinionModel_DHCSCYJ");
            objOpinion = $("#txtDHCSCYJ");
            $("#selOpinionModel_DHCSCYJ").css("display", "inline");
            $("#btnOpenOpinionModel_DHCSCYJ").css("display", "inline");
            $("#btnDelOpinionModel_DHCSCYJ").css("display", "inline");

            vUserName = $("#txtDHCSCR");
            vData = $("#txtDHCSCRQ");
            break;
        case 4:
            $("#tblSCYJ").css("display", "block");
            //$("#tblZSB").css("display", "block");
            $("#txtZSBSCYJ").removeAttr("disabled");
            $("#txtZSBSCR").removeAttr("disabled");
            $("#txtZSBSCRQ").removeAttr("disabled");
            $("#txtZSBSCYJ").css("background-color", "white");
            $("#txtZSBSCR").css("background-color", "white");
            $("#txtZSBSCRQ").css("background-color", "white");
            $('span[name="ZSBSCYJ"]').css("display", "inline");
            GetNowDate($("#txtZSBSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtZSBSCR"));
            objSel = $("#selOpinionModel_ZSBSCYJ");
            objSave = $("#btnOpenOpinionModel_ZSBSCYJ");
            objDel = $("#btnDelOpinionModel_ZSBSCYJ");
            objOpinion = $("#txtZSBSCYJ");
            $("#selOpinionModel_ZSBSCYJ").css("display", "inline");
            $("#btnOpenOpinionModel_ZSBSCYJ").css("display", "inline");
            $("#btnDelOpinionModel_ZSBSCYJ").css("display", "inline");

            vUserName = $("#txtZSBSCR");
            vData = $("#txtZSBSCRQ");
            break;
        case 10:
            $("#tblSCYJ").css("display", "block");
            //  $("#tblGHC").css("display", "block");
            $("#txtGHCSCYJ").removeAttr("disabled");
            $("#txtGHCSCR").removeAttr("disabled");
            $("#txtGHCSCRQ").removeAttr("disabled");
            $("#txtGHCSCYJ").css("background-color", "white");
            $("#txtGHCSCR").css("background-color", "white");
            $("#txtGHCSCRQ").css("background-color", "white");
            $('span[name="GHCSCYJ"]').css("display", "inline");
            GetNowDate($("#txtGHCSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtGHCSCR"));
            objSel = $("#selOpinionModel_GHCSCYJ");
            objSave = $("#btnOpenOpinionModel_GHCSCYJ");
            objDel = $("#btnDelOpinionModel_GHCSCYJ");
            objOpinion = $("#txtGHCSCYJ");
            $("#selOpinionModel_GHCSCYJ").css("display", "inline");
            $("#btnOpenOpinionModel_GHCSCYJ").css("display", "inline");
            $("#btnDelOpinionModel_GHCSCYJ").css("display", "inline");

            vUserName = $("#txtGHCSCR");
            vData = $("#txtGHCSCRQ");
            break;
        case 12:
            $("#tblSCYJ").css("display", "block");
            //$("#tblDJC").css("display", "block");
            $("#txtDJCSCYJ").removeAttr("disabled");
            $("#txtDJCSCR").removeAttr("disabled");
            $("#txtDJCSCRQ").removeAttr("disabled");
            $("#txtDJCSCYJ").css("background-color", "white");
            $("#txtDJCSCR").css("background-color", "white");
            $("#txtDJCSCRQ").css("background-color", "white");
            $('span[name="DJCSCYJ"]').css("display", "inline");
            GetNowDate($("#txtDJCSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtDJCSCR"));
            objSel = $("#selOpinionModel_DJCSCYJ");
            objSave = $("#btnOpenOpinionModel_DJCSCYJ");
            objDel = $("#btnDelOpinionModel_DJCSCYJ");
            objOpinion = $("#txtDJCSCYJ");
            $("#selOpinionModel_DJCSCYJ").css("display", "inline");
            $("#btnOpenOpinionModel_DJCSCYJ").css("display", "inline");
            $("#btnDelOpinionModel_DJCSCYJ").css("display", "inline");

            vUserName = $("#txtDJCSCR");
            vData = $("#txtDJCSCRQ");
            break;
        case 5:
            ShowOpinionBox(2);
            $("#txtFHYJ").removeAttr("disabled");
            $("#txt复核").removeAttr("disabled");
            $("#txtFHRQ").removeAttr("disabled");
            $("#txtFHYJ").css("background-color", "white");
            $("#txt复核").css("background-color", "white");
            $("#txtFHRQ").css("background-color", "white");
            $('span[name="FHYJ"]').css("display", "inline");
            GetNowDate($("#txtFHRQ"));
            GiveCurrentUserName2(vUserName, $("#txt复核"));
            objSel = $("#selOpinionModel_FHYJ");
            objSave = $("#btnOpenOpinionModel_FHYJ");
            objDel = $("#btnDelOpinionModel_FHYJ");
            objOpinion = $("#txtFHYJ");
            $("#selOpinionModel_FHYJ").css("display", "inline");
            $("#btnOpenOpinionModel_FHYJ").css("display", "inline");
            $("#btnDelOpinionModel_FHYJ").css("display", "inline");

            vUserName = $("#txt复核");
            vData = $("#txtFHRQ");
            break;
        case 6:
            ShowOpinionBox(3);
            $("#txtSHYJ").removeAttr("disabled");
            $("#txt审核").removeAttr("disabled");
            $("#txtSHRQ").removeAttr("disabled");
            $("#txtQFYJ").removeAttr("disabled");
            $("#txtSHYJ").css("background-color", "white");
            $("#txt审核").css("background-color", "white");
            $("#txtSHRQ").css("background-color", "white");
            $("#txtQFYJ").css("background-color", "white");
            $('span[name="SHYJ"]').css("display", "inline");
            GetNowDate($("#txtSHRQ"));
            GiveCurrentUserName2(vUserName, $("#txt审核"));
            objSel = $("#selOpinionModel_SHYJ");
            objSave = $("#btnOpenOpinionModel_SHYJ");
            objDel = $("#btnDelOpinionModel_SHYJ");
            objOpinion = $("#txtSHYJ");
            $("#selOpinionModel_SHYJ").css("display", "inline");
            $("#btnOpenOpinionModel_SHYJ").css("display", "inline");
            $("#btnDelOpinionModel_SHYJ").css("display", "inline");

            vUserName = $("#txt审核");
            vData = $("#txtSHRQ");
            break;
        case 7:
            ShowOpinionBox(4);
            $("#txtFGJZYJ").removeAttr("disabled");
            $("#txt签发").removeAttr("disabled");
            $("#txt签发时间").removeAttr("disabled");
            $("#txtFGJZYJ").css("background-color", "white");
            $("#txt签发").css("background-color", "white");
            $("#txt签发时间").css("background-color", "white");
            $('span[name="FGJZYJ"]').css("display", "inline");
            $("#tblFGJZ").css("display", "inline");
            GetNowDate($("#txt签发时间"));
            GiveCurrentUserName2(vUserName, $("#txt签发"));
            objSel = $("#selOpinionModel_FGJZYJ");
            objSave = $("#btnOpenOpinionModel_FGJZYJ");
            objDel = $("#btnDelOpinionModel_FGJZYJ");
            objOpinion = $("#txtFGJZYJ");
            $("#selOpinionModel_FGJZYJ").css("display", "inline");
            $("#btnOpenOpinionModel_FGJZYJ").css("display", "inline");
            $("#btnDelOpinionModel_FGJZYJ").css("display", "inline");

            vUserName = $("#txt签发");
            vData = $("#txt签发时间");
            break;
        case 8:
            ShowOpinionBox(5);
            $("#txtJZBGHYJ").removeAttr("disabled");
            $("#txtJZBGHSCR").removeAttr("disabled");
            $("#txtJZBGHSCRQ").removeAttr("disabled");
            $("#txtJZBGHYJ").css("background-color", "white");
            $("#txtJZBGHSCR").css("background-color", "white");
            $("#txtJZBGHSCRQ").css("background-color", "white");
            $('span[name="JZBGHYJ"]').css("display", "inline");
            $("#tblFGJZ").css("display", "inline");
            $("#tblJZBGH").css("display", "inline");
            GetNowDate($("#txtJZBGHSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtJZBGHSCR"));
            objSel = $("#selOpinionModel_JZBGHYJ");
            objSave = $("#btnOpenOpinionModel_JZBGHYJ");
            objDel = $("#btnDelOpinionModel_JZBGHYJ");
            objOpinion = $("#txtJZBGHYJ");
            $("#selOpinionModel_JZBGHYJ").css("display", "inline");
            $("#btnOpenOpinionModel_JZBGHYJ").css("display", "inline");
            $("#btnDelOpinionModel_JZBGHYJ").css("display", "inline");

            vUserName = $("#txtJZBGHSCR");
            vData = $("#txtJZBGHSCRQ");
            break;
        case 9:
            ShowOpinionBox(6);
            $("#txtZSBSFYJ").removeAttr("disabled");
            $("#txtZSBSFSCR").removeAttr("disabled");
            $("#txtZSBSFSCRQ").removeAttr("disabled");
            $("#txtZSBSFYJ").css("background-color", "white");
            $("#txtZSBSFSCR").css("background-color", "white");
            $("#txtZSBSFSCRQ").css("background-color", "white");
            $('span[name="ZSBSFYJ"]').css("display", "inline");
            GetNowDate($("#txtZSBSFSCRQ"));
            GiveCurrentUserName2(vUserName, $("#txtZSBSFSCR"));
            objSel = $("#selOpinionModel_ZSBSFYJ");
            objSave = $("#btnOpenOpinionModel_ZSBSFYJ");
            objDel = $("#btnDelOpinionModel_ZSBSFYJ");
            objOpinion = $("#txtZSBSFYJ");
            $("#selOpinionModel_ZSBSFYJ").css("display", "inline");
            $("#btnOpenOpinionModel_ZSBSFYJ").css("display", "inline");
            $("#btnDelOpinionModel_ZSBSFYJ").css("display", "inline");

            vUserName = $("#txtZSBSFSCR");
            vData = $("#txtZSBSFSCRQ");
            break;
        case "SF":
            $("table").css("display", "inline");
            $("#tblZSBSF").css("display", "none");
            $("#btnSave").css("display", "none");
            break;
        case "PHFZ":
            //$("#btnRKGD").removeAttr("disabled");
            //$("#btnRKGD").css("display", "block");
            $("table").css("display", "inline");
            $("#tblZSBSF").css("display", "none");
            $("#btnSave").css("display", "none");
            $("#tblFH").css("display", "none");
            $("#tblSHYJ").css("display", "none");

            $("#tblKGC").css("display", "none");
            $("#tblZSB").css("display", "none");
            break;
    }
    function ShowOpinionBox(obj) {
        $("#tblSCYJ").css("display", "block");
        //  $("#tblKGC").css("display", "block");
        //  $("#tblDHC").css("display", "block");
        // $("#tblZSB").css("display", "block");
        //$("#tblGHC").css("display", "block");
        // $("#tblDJC").css("display", "block");

        //        if (obj > 1)
        //            $("#tblFH").css("display", "block");
        //        if (obj > 2)
        //            $("#tblSHYJ").css("display", "block");
        if (obj > 3)
            $("#tblFGJZ").css("display", "block");
        if (obj > 4)
            $("#tblJZBGH").css("display", "block");
        if (obj > 5)
            $("#tblZSBSF").css("display", "block");
    }

    //保存申请页面信息
    $("#btnSave").click(function () {
        if (objOpinion == null || vUserName == null || vData == null) return;
        if ($(objOpinion).val().trim() == "") {
            alertex("意见不能为空", true);
            return false;
        }
        if ($(vUserName).val().trim() == "") {
            alertex("审查人不能为空", true);
            return false;
        }
        if ($(vData).val().trim() == "") {
            alertex("审查时间不能为空", true);
            return false;
        }
        $(":text").each(function () {
            m_cksqdj.SetValue($(this).attr("name"), $(this).val());
        });
        $("textarea").each(function () {
            m_cksqdj.SetValue($(this).attr("name"), $(this).val());
        });
        var res = m_cksqdj.Update();
        alertex(res, true);
    });
    $("#btnRKGD").click(function () {
        m_cksqdj.SetValue("XMLX", "1010");
        m_cksqdj.SetValue("XMZT", "0");
        alertex(m_cksqdj.Update(), true);
    });
    //时间控件绑定事件
    $("#txtSCRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtFHRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtSHRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtQFRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtJZBGHSCRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtKGCSCRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtDHCSCRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txtZSBSCRQ").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });
    $("#txt签发时间").click(function () {
        WdatePicker({ dateFmt: 'yyyy-M-d' });
    });

    var dlgZC1 = null;
    if (objSave != null) {
        $(objSave).click(function () {
            var dlgShowTOP = 100 + $(window.parent).scrollTop();
            var dlgShowWidth = ($(window).width() - 550) / 2 + window.parent.pageXOffset;

            dlgZC1 = $("#dlg-SelectStaff1").dialog({ modal: true, title: "填写要保存的意见模版名称", width: "550px", position: [dlgShowWidth, dlgShowTOP] });
            dlgZC1.dialog("open");
            var v = $("#" + $(objSel).attr("id") + " option:selected").text();
            $("#txtOpinionModelName").val(v);
        });
    }

    if (objSel != null) {
        //意见模版。
        BindOpinionModelList(objSel);
        $(objSel).change(function () {
            if ($(this).val() == "") return;
            var vId = $(objSel).val();
            var url = DBCenterServiceUrl + "/WLMQ_OpinionModel/WLMQ_OpinionModel.asmx/GetOpinionModelContent";
            var param = "{'ID':" + vId + "}";
            GetSmJSON(url, param, function (str) {
                $(objOpinion).val(str);
            });
        });
    }

    if (objDel != null) {
        $(objDel).click(function () {
            if (!confirm("确定要删除此条审批意见？"))
                return;
            var obj = $(objSel);
            var vId = $(obj).val();
            if (vId == "" || vId == "0") return;
            var url = DBCenterServiceUrl + "/WLMQ_OpinionModel/WLMQ_OpinionModel.asmx/DeleteOpinionModel";
            var param = "{'ID':" + vId + "}";
            GetSmJSON(url, param, function (json) {
                if (json != "") {
                    alertex(json);
                    $(objOpinion).val("");
                    BindOpinionModelList(obj);
                }
            });
        });
    }

    $("#btnSaveOpinionModel").click(function () {
        var objId = $(objSel).attr("id");
        var vName = $("#txtOpinionModelName").val();
        if (vName.trim() == "") {
            alertex("意见模版名称不能为空，请填写后保存。", true);
            return;
        }
        var vId = $(objSel).val() == null ? "0" : $(objSel).val();
        var vModelContent = $(objOpinion).val();
        var m_OpinionModel = new SmObjectData("CKQDJK", "意见模板");
        m_OpinionModel.GetFirstSmObject("BSM=0");
        m_OpinionModel.SetValue("BSM", vId);
        m_OpinionModel.SetValue("员工ID", staffID);
        m_OpinionModel.SetValue("工作流ID", "0");
        m_OpinionModel.SetValue("模板名称", vName);
        m_OpinionModel.SetValue("模板内容", vModelContent);
        m_OpinionModel.SetValue("部门ID", "0");
        m_OpinionModel.SetValue("备注", "");

        alertex(m_OpinionModel.Update(), true);
        BindOpinionModelList($(objSel));
        dlgZC1.dialog("close");
        //选中刚刚修改或者增加的意见
        if (vId == 0) {
            var vCnt = $("#" + objId + ">option").length - 1;
            $("#" + objId + ">option").eq(vCnt).prop("selected", true);
        } else {
            $("#" + objId + " option").each(function () {
                if ($(this).val() == vId) {
                    $(this).attr("selected", "true");
                    return;
                }
            });
        }
    });

    $(".m_textarea,.m_textarea_big").dblclick(function () {
        $(this).toggleClass("m_textarea_big2", 1000);
    });
});

function BindOpinionModelList(obj) {
    var url = DBCenterServiceUrl + "/WLMQ_OpinionModel/WLMQ_OpinionModel.asmx/GetOpinionModelList";
    var param = "{'UserId':" + staffID + ",'WorkflowID':0,'DepartmentID':0}";
    GetSmJSON(url, param, function (json) {
        callback(json, obj);
    });
}

function callback(json, obj) {
    if (obj == null) return;
    var data = JSON.parse(json);
    if (data.Rows.length == 0) return;
    $("#" + obj.attr("id") + " option").each(function () {
        $(this).remove();
    });
    var vhtml = '<option value="0"></option>';
    for (var i = 0; i < data.Rows.length; i++) {
        vhtml += '<option value="' + data.Rows[i][0] + '">' + data.Rows[i][2] + '</option>';
    }
    $(obj).html(vhtml);
}